import { Injectable } from '@angular/core';
import {API_URL_SPORT} from '../providers/Constants';
import { HttpService } from "./HttpService";

@Injectable()
export class SportService {
  constructor(
    private httpService: HttpService,

  ) { }

  //发布
 pubSport(sportModel){
    var url = API_URL_SPORT+"/create"
   return this.httpService.httpPost(url,sportModel)
 }
//获取列表
 getSportList(pageNum,pageSize,sportTypeId,sortCondition){
    var url = API_URL_SPORT+"/list?pageNum="+pageNum+"&&pageSize="+pageSize+"&&sportTypeId="+sportTypeId+"&&sortCondition="+sortCondition;
    return this.httpService.httpGet(url);
 }

 getSportDetail(id,userId){
    var url = API_URL_SPORT+"/select?id="+id+"&&userId="+userId;
    return this.httpService.httpGet(url);
 }

 joinSport(sportModel,userId){

    // JSON.parse(sportModel);
    sportModel.joinUserId = userId;
    var url = API_URL_SPORT+"/join";
    return this.httpService.httpPost(url,sportModel);
 }
 cancelJoinSport(sportId,userId){
   var url = API_URL_SPORT+"/cancelJoinSport?sportId="+sportId+"&&userId="+userId;
   return this.httpService.httpDelete(url);
 }
 cancelSport(sportId){
    // var body ={sportId:sportId};
    var url =API_URL_SPORT+'/cancelSport?sportId='+sportId;
    return this.httpService.httpGet(url);
 }
  selectListByUserId(userId){
    var url = API_URL_SPORT+'/selectListByUserId?userId='+userId;
    return this.httpService.httpGet(url);
  }
  selectIJoinSports(userId){
    var url = API_URL_SPORT+'/selectIJoinSports?userId='+userId;
    return this.httpService.httpGet(url);
  }
}
